package com.web.servlet;


import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.web.domain.Product;
import com.web.service.BaseService;
import com.web.service.ProductService;
import com.web.service.impl.ProductServiceImpl;

/**
 * 显示商品
 */
@WebServlet("/index") 
public class IndexServlet extends BaseService {
	private static final long serialVersionUID = 1L;
	
	@Override
	public String index(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		try {
			//调用ProductService查询商品
			ProductService ps = new ProductServiceImpl();
			List<Product> hotList =  ps.findHot();
			//将两个List放入域中
			request.setAttribute("hList", hotList);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "/jsp/index.jsp";
	}
}
